//
//  BLEConfig.h
//  IKBLELibrary
//
//  Created by Shanlin on 16/5/11.
//  Copyright © 2016年 zhuxin. All rights reserved.
//

#ifndef BLEConfig_h
#define BLEConfig_h

#ifdef __OBJC__

#import <Foundation/Foundation.h>
// .h
#define ble_single_interface(class)  + (class *)shared##class;

// .m
#define ble_single_implementation(class) \
static class *_instance; \
\
+ (class *)shared##class \
{ \
if (_instance == nil) { \
_instance = [[self alloc] init]; \
} \
return _instance; \
} \
\
+ (id)allocWithZone:(NSZone *)zone \
{ \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
_instance = [super allocWithZone:zone]; \
}); \
return _instance; \
}

typedef NS_ENUM(NSInteger,DeviceType) {
    DeviceTypeHeart,
    DeviceTypeSleepAce,
    DeviceTypeBlood,
    DeviceTypeTapchBlood,
    DeviceTypeTapchGluco,
    DeviceTypeButt,
};

//typedef NS_ENUM(NSInteger,BLECommon) {
//    //ECG
//    BLECommonECGHeartRate = 0,
//    BLECommonECGRRInterval = 1,
//    BLECommonECGBreathRate = 2,
//};
typedef NS_ENUM (NSInteger,BLEErrorCode){
    BLEErrorCodeSuccess = 0,
    BLEErrorCodeOpen ,
    BLEErrorCodeNotOpen ,
    BLEErrorCodeConnecting,
    BLEErrorCodeDidDisconnectPeripheral,
    BLEErrorCodeUnauthorized
};


typedef NS_ENUM(NSInteger,ECGType)
{
    TYPE_HEART_RATE = 0,          /* heart rate */
    TYPE_RDETECT = 1,             /* RR interval */
    TYPE_BREATH_RATE = 2,         /* breath rate */
    TYPE_ABNORMAL = 3,            /* real time abnormal report */
    
    TYPE_EMOTION = 4,             /* emotion */
    TYPE_SNS = 5,                  /* sympathetic nervous system */
    TYPE_PNS = 6,                  /* peripheral nervous system */
    TYPE_STRESS_INDEX = 7,        /* russia stress index */
    TYPE_KHMI = 8,                 /* ikinloop harmony index */
    TYPE_HEART_AGE = 9,           /* heart age */
    TYPE_HRV_SDNN = 10,           /* sdnn of HRV */
    
    TYPE_PREMATURE_BEAT = 11,     /* premature beat times */
    TYPE_AVERAGE_HR = 12,          /* average heart rate */
    
    TYPE_RESET_APP = 13,           /* app reset ecg test when receiving this callback */
    
    TYPE_MAX_HEART_RATE = 14,     /* max heart rate */
    TYPE_MIN_HEART_RATE = 15,     /* min heart rate */
    
    TYPE_THIS_TEST_INVALID = 16,  /* value=1 means after test complete, ecg data has too much noise, abort data analyze */
    TYPE_THIS_TEST_Astril = 17,  /* value=1 means after test complete, ecg data is AstrilF 1 房颤 0 没有*/
    TYPE_THIS_TEST_KM = 18 ,     /* value=0 means normal, 1 means fast,2 means slow 0 正常, 1 心动过速 2 心动过缓*/
    TYPE_THIS_TEST_Disfrm = 19,     /* value=1 means disform, 0 means OK  1 心率不齐, 0 正常*/
    TYPE_HEART_BUTT
};

typedef NS_ENUM(NSInteger,BLE_ConnectType)
{
    BLE_ConnectType_BODY = 0,          /* device is touched by human body */
    BLE_ConnectType_WIRE = 1,         /* usb wire is plugged */
    BLE_ConnectType_HEART_RATE = 2,          /* heart rate directly from device */
    BLE_ConnectType_ABNORMAL = 3,            /* device internal fatal erro */
    BLE_TYPE_NOTKNOW
};


#define UUID(uuid) [NSString stringWithFormat:@"0000%@-0000-1000-8000-00805F9B34FB",uuid]
#define FULL_UUID(uuid) (uuid.length > 4 ? uuid : UUID(uuid))

#endif

#endif /* BLEConfig_h */
